package com.tang;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/*
* rabbitmq集成spring 发送消息
* */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:spring-rabbitmq-producer.xml")
public class text {
    @Autowired
    private RabbitTemplate  rabbitTemplate;

    @Test
    public void ceshi(){
        //发送消息
        rabbitTemplate.convertAndSend("spring_queue","world");
    }
/*发送 fanout  消息
* */
    @Test
    public void fanout(){
        //发送消息
        rabbitTemplate.convertAndSend("spring_fanout_exchange","","spring ~~");
    }

    /*发送 Topics  消息
     * */
    @Test
    public void ceshiTopics(){
        //发送消息
        rabbitTemplate.convertAndSend("spring_topic_exchange","tang.he.hh","spring 1~~");
    }
}
